<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD><TITLE>Tcl_WrongNumArgs manual page - Tcl Library Procedures</TITLE>
<link rel="stylesheet" href="../docs.css" type="text/css" media="all">
</HEAD>
<BODY><H2><a href="../contents.htm">Tcl8.6.11/Tk8.6.11 Documentation</a> <small>&gt;</small> <a href="contents.htm">Tcl C API</a> <small>&gt;</small> WrongNumArgs</H2>
<H3><A HREF="../UserCmd/contents.htm">Tcl/Tk Applications</A> | <A HREF="../TclCmd/contents.htm">Tcl Commands</A> | <A HREF="../TkCmd/contents.htm">Tk Commands</A> | <A HREF="../ItclCmd/contents.htm">[incr Tcl] Package Commands</A> | <A HREF="../SqliteCmd/contents.htm">SQLite3 Package Commands</A> | <A HREF="../TdbcCmd/contents.htm">TDBC Package Commands</A> | <A HREF="../TdbcmysqlCmd/contents.htm">tdbc::mysql Package Commands</A> | <A HREF="../TdbcodbcCmd/contents.htm">tdbc::odbc Package Commands</A> | <A HREF="../TdbcpostgresCmd/contents.htm">tdbc::postgres Package Commands</A> | <A HREF="../TdbcsqliteCmd/contents.htm">tdbc::sqlite3 Package Commands</A> | <A HREF="../ThreadCmd/contents.htm">Thread Package Commands</A> | <A HREF="../TclLib/contents.htm">Tcl C API</A> | <A HREF="../TkLib/contents.htm">Tk C API</A> | <A HREF="../ItclLib/contents.htm">[incr Tcl] Package C API</A> | <A HREF="../TdbcLib/contents.htm">TDBC Package C API</A></H3>
<H3><A NAME="M2">NAME</A></H3>
Tcl_WrongNumArgs &mdash; generate standard error message for wrong number of arguments
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>#include &lt;tcl.h&gt;</B><BR>
<B>Tcl_WrongNumArgs</B>(<I>interp, objc, objv, message</I>)<BR>
<H3><A NAME="M4">ARGUMENTS</A></H3>
<DL class="arguments">
<DT><A HREF="../TclLib/Interp.htm">Tcl_Interp</A> <B><A HREF="../TclCmd/interp.htm">interp</A></B> (in)<DD>
Interpreter in which error will be reported: error message gets stored
in its result value.
<P><DT>int <B>objc</B> (in)<DD>
Number of leading arguments from <I>objv</I> to include in error
message.
<P><DT><A HREF="../TclLib/Object.htm">Tcl_Obj</A> *const <B>objv[]</B> (in)<DD>
Arguments to command that had the wrong number of arguments.
<P><DT>const char <B>*message</B> (in)<DD>
Additional error information to print after leading arguments
from <I>objv</I>.  This typically gives the acceptable syntax
of the command.  This argument may be NULL.
<P></DL>
<H3><A NAME="M5">DESCRIPTION</A></H3>
<B>Tcl_WrongNumArgs</B> is a utility procedure that is invoked by
command procedures when they discover that they have received the
wrong number of arguments.  <B>Tcl_WrongNumArgs</B> generates a
standard error message and stores it in the result value of
<I>interp</I>.  The message includes the <I>objc</I> initial
elements of <I>objv</I> plus <I>message</I>.  For example, if
<I>objv</I> consists of the values <B>foo</B> and <B>bar</B>,
<I>objc</I> is 1, and <I>message</I> is
&ldquo;<B>fileName count</B>&rdquo;
then <I>interp</I>'s result value will be set to the following
string:
<P>
<PRE>wrong # args: should be &quot;foo fileName count&quot;</PRE>
<P>
If <I>objc</I> is 2, the result will be set to the following string:
<P>
<PRE>wrong # args: should be &quot;foo bar fileName count&quot;</PRE>
<P>
<I>Objc</I> is usually 1, but may be 2 or more for commands like
<B><A HREF="../TclCmd/string.htm">string</A></B> and the Tk widget commands, which use the first argument
as a subcommand.
<P>
Some of the values in the <I>objv</I> array may be abbreviations for
a subcommand.  The command
<B><A HREF="../TclLib/GetIndex.htm">Tcl_GetIndexFromObj</A></B> will convert the abbreviated string value
into an <I>indexObject</I>.  If an error occurs in the parsing of the
subcommand we would like to use the full subcommand name rather than
the abbreviation.  If the <B>Tcl_WrongNumArgs</B> command finds any
<I>indexObjects</I> in the <I>objv</I> array it will use the full subcommand
name in the error message instead of the abbreviated name that was
originally passed in.  Using the above example, let us assume that
<I>bar</I> is actually an abbreviation for <I>barfly</I> and the value
is now an <I>indexObject</I> because it was passed to
<B><A HREF="../TclLib/GetIndex.htm">Tcl_GetIndexFromObj</A></B>.  In this case the error message would be:
<P>
<PRE>wrong # args: should be &quot;foo barfly fileName count&quot;</PRE>
<H3><A NAME="M6">SEE ALSO</A></H3>
<B><A HREF="../TclLib/GetIndex.htm">Tcl_GetIndexFromObj</A></B>
<H3><A NAME="M7">KEYWORDS</A></H3>
<A href="../Keywords/C.htm#command">command</A>, <A href="../Keywords/E.htm#error message">error message</A>, <A href="../Keywords/W.htm#wrong number of arguments">wrong number of arguments</A>
<div class="copy">Copyright &copy; 1994-1997 Sun Microsystems, Inc.
</div>
</BODY></HTML>
